﻿/**
 * @author sminutoli
 * version 1.0
 * 
 * este PressButton recibe un linkageID para levantar un clip de la librería.
 * Este clip está vinculado a una clase de ActionScript, que implementa ButtonCentral
 * PressButtonViewBotoneraCentral se encarga de vincular el PressButtonControl con el movieClip final
 * 
 * version 1.01
 * se agrega un buttonRelease()
 * 
 */
 
import com.dinmax.flash.draw.control.button.PressButtonView;
import com.dinmax.flash.draw.control.button.PressButtonViewItem;
import com.dinmax.flash.draw.control.ImageLoader;
import com.dinmax.flash.central.draw.ButtonCentral;

class com.dinmax.flash.central.draw.PressButtonViewBotoneraCentral implements
PressButtonView {
		
	private var button:ButtonCentral;
	private var link:String;
	
	public function PressButtonViewBotoneraCentral(link:String) {
		this.reset();
		this.setLink(link);
	}
	
	public function buttonHover(container:MovieClip):MovieClip{
		button.setHover();
		return container;
	};
	
	public function buttonPress(container:MovieClip):MovieClip{
		return container;
	};
	
	public function buttonRelease(container:MovieClip):MovieClip{
		return this.buttonPress(container);	
	};
	
	public function buttonNormal(container:MovieClip):MovieClip{
		button.setNormal();
		return container;
	};
	public function buttonDisable(container:MovieClip):MovieClip{
		button.setDisabled();
		return container;
	};
		
	public function tooltip(container:MovieClip, text:String):MovieClip{
		return container;	
	};
	public function border(container:MovieClip):MovieClip{
		if(button==undefined){
			button= ButtonCentral(container.attachMovie(this.getLink(), "mcButtonCentral", container.getNextHighestDepth()));
			button.onLoad=function(){
				this.setSize(container.width, container.height);
			}
		} else {
			button.setSize(container.width, container.height);
		}
		return container;
	};
	
	public function setText(text:String){
		button.setText(text);
	};
	
	public function attachImage(container:MovieClip, path:String):MovieClip {
		ImageLoader.loadImage(container, path);
		return container;
	};
	
	public function reset(){
		// acá debería inicializar la vista, generar los formatos, etc.
		//trace("PressButtonViewCentral.as | reset()");
	};
		
	public function getLink():String {
		return link;
	}

	public function setLink(link:String):Void {
		this.link = link;
	}

}